package comWorld.listener;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import com.gjs.tools.JDBC.JDBCTools;

import webManage.FileManage;

/**
 * Application Lifecycle Listener implementation class AppInitListener
 *
 */
@WebListener
public class AppInitListener implements ServletContextListener {

    /**
     * Default constructor. 
     */
    public AppInitListener() {
    }

	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent event)  {
    	ServletContext app = event.getServletContext();
    }

	/**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent event)  {
    	ServletContext app = event.getServletContext();
    	FileManage.createDirectory(app.getRealPath(FileManage.MAINDIR));
    	FileManage.createDirectorys(app.getRealPath(FileManage.MAINDIR + "uploads/portrait/"));
//    	JDBCTools.initDataSource();
    }
}
